import { createRouter, createWebHistory } from 'vue-router'

/* import Home from '../views/Home.vue'
import About from '../views/About.vue' */

// 创建一个路由, 映射关系
const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: '/',
      redirect: '/home',
    },
    {
      path: '/home',
      component: () =>
        import(/* webpackChunkName: 'home' */ '../views/Home.vue'),
      name: 'home',
      // 自定义属性
      meta: {
        name: 'why',
      },
    },
    {
      path: '/about',
      component: () =>
        import(/* webpackChunkName: 'about' */ '../views/About.vue'),
      name: 'about',
    },
    {
      path: '/user/:id?',
      component: () =>
        import(/* webpackChunkName: 'user' */ '../views/User.vue'),
      name: 'user',
    },
    {
      path: '/:pathMatch(.*)*',
      component: () =>
        import(/* webpackChunkName: 'NotFound' */ '../views/NotFound.vue'),
      name: 'NotFound',
    },
  ],
})

export default router
